﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;
using System.Windows.Forms;

namespace OALPTool
{
    class DgvColEdit
    {
        public static int ReadDgFuncSort(string CorpNo,string UserNo,string FuncNo,string wheresql ,out DataSet ds,out string strMsg) 
        {
            ds = null;
            strMsg = "";
            //string corpschema = ISysPlatformFunc.GetCorpSchema();

            //string strsql = "select "
            //    + " dfs.ViewSortID,dfs.FieldNameCh,dfs.FieldName,"
            //    + " (case dfs.ViewFlag when '0' then '是' when '1' then '否' end) as ViewFlag,"
            //    + " dfs.ViewSeqNo,dfs.SortNo,dfs.SortFlag,dfs.CtrlType,dfs.ViewWidth,dfs.ViewFormat,"
            //    + " dfs.ViewAlign,dfs.EditAble,dfs.nullText,dfs.IsValueMean,df.UserNo,df.CorpNo,df.FuncNo from " + corpschema + ".sal_dgfuncsort dfs "
            //    + "left join " + corpschema + ".sal_dgfunc df on df.FuncNO = dfs.FuncNO where df.UserNo = '" + UserNo
            //    + "' and df.CorpNo = '" + CorpNo + "' and df.FuncNo = '" + FuncNo + "' " + wheresql + " order by dfs.ViewSeqNo";

            //int ret = ISysPlatformFunc.OpenSql(strsql, out ds, out strMsg);
            //if (ret != 0) return ret;

            return 0;
        }

        public static int ReadDgvColData(string CorpNo, string wheresql, out DataSet ds, out string strMsg)
        {
            ds = null;
            strMsg = "";
            //string corpschema = ISysPlatformFunc.GetCorpSchema();

            //string strsql = "SELECT "
            //              + " JS,"
            //              + " QZE,"
            //              + " JZE,"
            //              + " SL,"
            //              + " SSKCS "
            //              + " FROM " + corpschema + ".SAL_SDSSL "
            //              + " WHERE 1=1" + wheresql
            //              + " ORDER BY JS";

            //int ret = ISysPlatformFunc.OpenSql(strsql, out ds, out strMsg);
            //if (ret != 0) return ret;

            return 0;
        }

        public static int SaveDgvCol(string CorpNo, DataGridView dgv,string funcno, out string strMsg)
        {
            strMsg = "";
            //string corpschema = ISysPlatformFunc.GetCorpSchema();

            //ArrayList strsqls = new ArrayList();
            //string strsql = "delete from " + corpschema + ".sal_dgfuncsort where funcno = '" + funcno + "'";
            //strsqls.Add(strsql);

            //foreach (DataGridViewRow dvr in dgv.Rows) 
            //{
            //    strsql = "insert into " + corpschema + ".sal_dgfuncsort(VIEWSORTID,FUNCNO,FIELDNAMECH,FIELDNAME,VIEWFLAG,VIEWSEQNO,SORTNO,SORTFLAG,CTRLTYPE,VIEWWIDTH,VIEWFORMAT,VIEWALIGN,EDITABLE,NULLTEXT,ISVALUEMEAN) VALUES ("
            //           + "1,'"+funcno+"','"+ dvr.Cells[0];
            //}


            //int ret = ISysPlatformFunc.ExecSql(strsqls, out strMsg);
            //if (ret != 0) return ret;

            return 0;
        }

        public static int DelDgvCol(DataRow dr, out string strMsg)
        {
            strMsg = "";
            return 0;
        }
    }
}
